<br>
<div class="message">

  <% if (user) { %>
  <form method="post" action="/comment/<%= post.name %>/<%= post.time.minute %>/<%= post.title %>">
    发布人:<%= user.name %>
    <input type="hidden" name="name" value="<%= user.name %>"/><br><br>
    <textarea name="content" rows="7" style="width: 100%;"></textarea><br>
    <input id="reply" type="submit" value="留言" />
  </form>
  <% }else{ %>
  <form id="unreply" method="post">
    回应请先<a class="unreply" href="/login">登录</a>或<a class="unreply" href="/reg">注册</a>
    <textarea name="content" rows="5" style="width: 100%;" id="tb"></textarea><br>
    <input type="submit" value="留言" id="sb" />
  </form>
  <% } %>

<% post.comments.forEach(function(comment){ %>
<p class="respond">
  <%= comment.name %>
  <span> 回复于 <%= comment.time %></span>
</p>
  <div class="reply">
<p><%- comment.content %></p>
  </div>
<% })%>

</div>
<script>
  window.onload = function(){
    var textarea = document.querySelector('#tb');
    var button  = document.querySelector('#sb');
    button.onclick = function(e){
      e.preventDefault();
      location.href = '/login';
    }
    textarea.onfocus = function(){
      location.href =  '/login';
    }
  }
</script>
